<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<button>click</button>
<div></div>
<script>
  var btn = document.querySelector('button');
  var div = document.querySelector('div');

  btn.addEventListener('click', function () {
    location.href = 'http://www.baidu.com';
  })

  var time = 5;
  var timer = setInterval(function () {
    if (time === 0) {
      clearInterval(timer);
      location.href = 'http://www.baidu.com';
    } else {
      div.innerHTML = '剩余' + time + '秒转跳';
      time--;
    }
  }, 1000)
</script>
</body>
</html>